package com.wanyang.dto;

import com.wanyang.dos.NewsDO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Data
public class PostPublishNews extends PostPublishBase {

    private News news;

    @Data
    public static class News extends NewsDO {
        @ApiModelProperty(value = "1-文本，2-视频")
        private Integer type;
        @ApiModelProperty(value = "副文本内容，type=1时填该字段")
        private String content;
        @ApiModelProperty(value = "富文本中的所有图片")
        private List<String> imgList;

        @ApiModelProperty(value = "视频url，type=2时填该字段")
        private String videoUrl;
        @ApiModelProperty(value = "视频封面")
        private String videoCover;

    }

    @Override
    public Object getDetailObject() {
        return news;
    }

    @Override
    public AuditObject getNeedAuditObject() {
        AuditObject auditObject = new AuditObject();
        if (news.getType() == 1) {
            auditObject.setContents(Arrays.asList(this.getTitle(), this.news.getContent()));
            auditObject.setImgList(news.imgList);
        } else {
            auditObject.setContents(Collections.singletonList(this.getTitle()));
            auditObject.setVideoList(Collections.singletonList(news.getVideoUrl()));
        }
        return auditObject;
    }
}
